<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
	</head>

	<body>

		<div style="width: 100%;height: 10px;"></div>
		<div class="accountManagerHeader" style="width: 100%;height: 40px;">
			<div class="accountManagerHeaderContent" style="width: 95%;height: 80%; margin: auto;">
				<span class="mui-action-back mui-icon mui-icon-back"></span>
				<span class="accountManagerCharacter" style="margin-left: 27%;">账号管理</span>
			</div>
		</div>
		<div id="form1">
			<div class="mui-input-row">
				<label></label>
				<input id="old" type="password" placeholder="新密码" style="width: 95%;">
			</div>
			<div class="mui-input-row">
				<label></label>
				<input id="new" type="password" placeholder="再次输入" style="width: 95%;">
			</div>

			<div style="width: 100%;height:50px;"></div>
			<div class="buttongroup" style="width: 174px;margin: auto;">
				<button id="code" type="button" class="mui-btn mui-btn-royal">修改密码</button>
				<button id="account" type="button" class="mui-btn mui-btn-royal">退出账号</button>
			</div>
			<div style="width: 100%;height: 40px;"></div>
			<div style="width: 100%;height:50px;color: gray;">
				<div style="width: 80%;height:80%;margin: auto;">
					<div style="font-size: 12px;">退出账号时</div>
					<div style="font-size: 12px;">关注的漫画将会保存到您的个人账号</div>
					<div style="font-size: 12px;">最近观看与下载的漫画将会保存到您的设备上</div>
				</div>
			</div>

			<script src="js/url.js"></script>
			<script src="js/jquery.min.js"></script>
			
			<script src="js/mui.min.js"></script>
			
			<script>
				mui.init()
				$.noConflict();


				jQuery.ajax({
					
					type: 'post',
					url: serverip.ip + '/accountManagertest',
					
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					
					success: function(data) {
						console.log(data)
						if(data != 1) {
						
						mui.openWindow('login.html')
							
						}
					},error:function(){
						console.log(11111)
					}
				});

				jQuery('input').blur(function() {
					if(document.getElementById('old').value != null &&
						document.getElementById('new') != null &&
						document.getElementById('old').value == document.getElementById('new').value) {

						jQuery('#code').bind("tap", function() {
							var newcode = jQuery('#new').val();
							jQuery.ajax({
								type: 'post',
								url: serverip.ip + '/changeCode',
								data: {
									'newCode': newcode
								},
								dataType: 'json',
								xhrFields: {
									withCredentials: true
								},
								crossDomain: true,
								success: function(data) {
									if(data == '请登录') {
										mui.openWindow({
											url: 'login.html'
										})
									} else {
										alert('成功')
									}
								}
							});
						})

					}
				});

				jQuery('#account').bind("tap", function() {
					jQuery.ajax({
								type: 'post',
								url: serverip.ip + '/exit',
								
								dataType: 'json',
								xhrFields: {
									withCredentials: true
								},
								crossDomain: true,
								success: function(data) {
									
									if(data == 1) {
										
										mui.openWindow({
											url: 'login.html'
										})
									} 
								}
							});
				});
			</script>

			
	</body>

</html>